var fs=require('fs');

function copyFile(from,to){

    console.log('start to read');
    fs.readFile(from,function(err,content){
        if(err){
            console.log('read error or no such file');
            return console.error(err);
        }else{
            writeFile(to,content);
            return content;
        }
    });
}

function writeFile(to,content){

    fs.writeFile(to,content,'utf-8',function(err){
        if(err){
            throw err;
        }else{
            console.log('write success');
        }
    });

}

// copyFile('abd.txt','bcd.txt');
copyFile('abc.txt','bcd.txt');
